﻿using System;
using SharpSqlAnalyzer.nodes;
using SharpSqlAnalyzer.pp.para;
using SharpSqlAnalyzer.pp.processor.type.comm;
using SharpSqlAnalyzer.pp.utils;
using SharpSqlAnalyzer.stmt;

namespace SharpSqlAnalyzer.pp.processor.type.createtable
{
	// Token: 0x02000246 RID: 582
	public class CreateTableBEInNewLineProcessor : AbstractProcessor
	{
		// Token: 0x06001303 RID: 4867 RVA: 0x0031C174 File Offset: 0x0031A374
		public override void process(TParseTreeNode nodeArg)
		{
			TCreateTableSqlStatement tcreateTableSqlStatement = nodeArg as TCreateTableSqlStatement;
			bool? flag = new bool?(this.getParameter<bool>(typeof(bool)));
			bool? flag2 = new bool?(this.getParameter<bool>(typeof(bool), 1));
			bool? flag3 = new bool?(this.getParameter<bool>(typeof(bool), 2));
			TColumnDefinitionList columnList = tcreateTableSqlStatement.ColumnList;
			if (columnList != null && columnList.size() > 0)
			{
				int num = SourceTokenOperator.curIndentLenVT(tcreateTableSqlStatement.startToken);
				TSourceToken tsourceToken = SourceTokenSearcher.backforwardSearch(columnList.startToken, 3, "(");
				if (tsourceToken != null)
				{
					SourceTokenOperator.removeWhitespaceAndReturnFromEnd(this.Option, tsourceToken);
					SourceTokenOperator.removeWhitespaceAndReturnFromStart(this.Option, tsourceToken.container, tsourceToken.posinlist + 1);
					if (flag3 != null)
					{
						bool? flag4 = flag3;
						bool flag5 = true;
						if (flag4.GetValueOrDefault() == flag5 & flag4 != null)
						{
							SourceTokenOperator.addAfter(this.Option, tsourceToken, SourceTokenOperator.createReturnSourceToken());
						}
					}
					if (flag != null)
					{
						bool? flag4 = flag;
						bool flag5 = true;
						if (flag4.GetValueOrDefault() == flag5 & flag4 != null)
						{
							SourceTokenOperator.addBefore(this.Option, tsourceToken, SourceTokenOperator.createReturnSourceToken());
							SourceTokenOperator.addBefore(this.Option, tsourceToken, SourceTokenOperator.createWhitespaceSourceToken(num + this.Option.indentLen));
							if (flag3 == null)
							{
								goto IL_1DA;
							}
							flag4 = flag3;
							flag5 = true;
							if (flag4.GetValueOrDefault() == flag5 & flag4 != null)
							{
								SourceTokenOperator.addAfter(this.Option, tsourceToken, SourceTokenOperator.createWhitespaceSourceToken(num + this.Option.indentLen * 2));
								goto IL_1DA;
							}
							goto IL_1DA;
						}
					}
					if (flag3 != null)
					{
						bool? flag4 = flag3;
						bool flag5 = true;
						if (flag4.GetValueOrDefault() == flag5 & flag4 != null)
						{
							SourceTokenOperator.addAfter(this.Option, tsourceToken, SourceTokenOperator.createWhitespaceSourceToken(num + this.Option.indentLen));
						}
					}
				}
				IL_1DA:
				TSourceToken tsourceToken2 = SourceTokenSearcher.forwardSearch(columnList.endToken.container.get(columnList.endToken.posinlist + 1), 3, ")");
				if (tsourceToken2 != null)
				{
					SourceTokenOperator.removeWhitespaceAndReturnFromEnd(this.Option, tsourceToken2);
					SourceTokenOperator.removeWhitespaceAndReturnFromStart(this.Option, tsourceToken2.container, tsourceToken2.posinlist + 1);
					if (flag2 != null)
					{
						bool? flag4 = flag2;
						bool flag5 = true;
						if (flag4.GetValueOrDefault() == flag5 & flag4 != null)
						{
							SourceTokenOperator.addBefore(this.Option, tsourceToken2, SourceTokenOperator.createReturnSourceToken());
							GFmtOpt option = this.Option;
							TSourceToken targetToken = tsourceToken2;
							int num2 = num;
							int num3;
							if (flag != null)
							{
								flag4 = flag;
								flag5 = true;
								if (flag4.GetValueOrDefault() == flag5 & flag4 != null)
								{
									num3 = this.Option.indentLen;
									goto IL_2A9;
								}
							}
							num3 = 0;
							IL_2A9:
							SourceTokenOperator.addBefore(option, targetToken, SourceTokenOperator.createWhitespaceSourceToken(num2 + num3));
						}
					}
				}
			}
		}
	}
}
